package GUI;

import 试题和试卷.paper;

import javax.swing.*;
import java.awt.*;

public class demoExerciseWindow extends JFrame {
    JPanel panel = new JPanel(new GridLayout(4, 1,20,20));

    JLabel successLab=new JLabel();
    JLabel numberLab=new JLabel();
    JLabel demoLab=new JLabel();
    JLabel lab2=new JLabel(" ");

    public demoExerciseWindow(){}

    public demoExerciseWindow(paper currentpaper){
        this.setSize(200,150);
        Font bigFont = new Font("sanserif",Font.PLAIN,15);

        Runnable r = () -> {
            String name=currentpaper.getName();
            int questionNumber=currentpaper.getQuestionNumber();
            int def=currentpaper.getDefinitionNumber();
            int fil=currentpaper.getFillingBlankNumber();
            int sel=currentpaper.getSelectionNumber();
            int sub=currentpaper.getsubjectiveNumber();
            successLab.setText(name);
            successLab.setFont(bigFont);
            numberLab.setText(currentpaper.questionSet.get(0).getText()+currentpaper.questionSet.get(1).getTitle()+
                    currentpaper.questionSet.get(1).getText()+currentpaper.questionSet.get(1).getType());
            /*这里测试能否成功，看来导入试题是完全没有问题的（只要创建了试题的table，下面需要创建窗体）*/
            panel.setSize(demoExerciseWindow.this.getSize());
            panel.add(lab2);
            panel.add(successLab);
            panel.add(numberLab);
            demoExerciseWindow.this.getContentPane().add(BorderLayout.CENTER,panel);
            demoExerciseWindow.this.setLayout(new FlowLayout());//流式布局
            demoExerciseWindow.this.setLocationRelativeTo(null);//居中

            demoExerciseWindow.this.setTitle("在线考试平台");
            demoExerciseWindow.this.setVisible(true);
            //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        };
        Thread tim=new Thread(r);
        tim.run();
    }

}
